package com.gitee.wsl.compose.mvi.ui.snackbar

import androidx.compose.material3.Snackbar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.gitee.wsl.compose.mvi.component.Projector


class SnackbarProjector(
    interactor: SnackbarInteractor,
    presenter: SnackbarPresenter = SnackbarPresenter.Default
) : Projector<SnackbarInteractor, SnackbarPresenter>(interactor, presenter) {


    @Composable
    override fun body(
        combinedModifier: Modifier,
        interactor: SnackbarInteractor,
        presenter: SnackbarPresenter,
    ) {
        Snackbar(
            snackbarData = interactor.data,
            modifier = combinedModifier,
            actionOnNewLine = presenter.actionOnNewLine.toBoolean(),
            shape = presenter.shape,
            containerColor = presenter.backgroundColor,
            contentColor = presenter.contentColor,
            actionColor = presenter.actionColor,
            //elevation = presenter.elevation
        )
    }
}

@Composable
fun Snackbar(modifier: Modifier = Modifier,
             interactor: SnackbarInteractor,
             presenter: SnackbarPresenter = SnackbarPresenter.Default) = SnackbarProjector(interactor,presenter)(modifier)